package com.it.page;

import com.fasterxml.jackson.annotation.JsonUnwrapped;
import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.Min;

@Data
public class PageQuery<T> {
    public static final int DEFAULT_PAGE = 1;

    public static final int DEFAULT_PAGE_SIZE = 10;

    @Min(1)
    private int page;

    @Min(1)
    private int pageSize;

    @JsonUnwrapped
    @Valid
    private T queryBody;

    private String webSort;

    public PageQuery() {
        this(DEFAULT_PAGE, DEFAULT_PAGE_SIZE);
    }

    public PageQuery(int page, int pageSize) {
        this.page = page;
        this.pageSize = pageSize;
    }
}
